import { TableColumn } from "@/components/GuatTable/types";
import GuatActions from "@/components/GuatActions/index.vue";
import Permissions from "@/constant/permission";
import { Tag } from "@arco-design/web-vue";

interface NoticeListTableMethods {
  chk: () => void;
  hide: () => void;
  del: () => void;
}

export const createTableColumns = (methods: NoticeListTableMethods): TableColumn[] => {
  return [
    {
      title: "公告标题",
      dataIndex: "noticeTitle",
    },
    {
      title: "公告类型",
      dataIndex: "noticeType",
    },
    {
      title: "发布日期",
      dataIndex: "noticePostTime",
    },
    {
      title: "截止日期",
      dataIndex: "noticeEndTime",
    },
    {
      title: "当前状态",
      render: ({ noticeStatus }) => {
        return (
          <Tag size="large" color={noticeStatus == "投放中" ? "green" : undefined}>
            {noticeStatus}
          </Tag>
        );
      },
    },
    {
      title: "操作",
      width: 130,
      render: () => {
        return (
          <GuatActions
            actions={[
              { internal: "check", onClick: methods.chk },
              {
                icon: "ph:eye-slash",
                color: "blue",
                permission: Permissions.NOTICE_HIDE,
                onClick: methods.hide,
              },
              { internal: "delete", permission: Permissions.NOTICE_DEL, onClick: methods.del },
            ]}
          />
        );
      },
    },
  ];
};
